<?php
declare (strict_types = 1);
namespace app\api\controller;
use app\api\BaseController;
// use app\api\middleware\Auth;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use think\facade\Db;
use think\facade\Request;
use think\facade\Filesystem;
use think\facade\Session;
use think\Image;
use think\Model;
// use think\Request;

// 上传类
class Upload extends BaseController
{
	protected $middleware = [
    	
    ];
   // 上传方法
   public function upload()
   {
   	$file = request()->file('file');
	$param= request()->param();
	$file_path=uploadfile($file);
   	if($file_path){
   		$result=Db::name('member')->where(['id'=>$param['id']])->update(['avatarUrl'=>$file_path]);
   		$info=Db::name('member')->where(['id'=>$param['id']])->find();
        $info['avatarUrl']=imgurl($info['avatarUrl']);
   		 return json(['code'=>200,'msg'=>'更新成功','data'=>$info]);
   	}else{
   		 return json(['code'=>404,'msg'=>'更新失败']);
   	}
   }
}
